package com.shujia.wyh.day12;

import java.io.*;

/*
    字符流：
        字符输入流：Reader -- InputStreamReader -- FileReader
        字符输出流：Writer -- OutputStreamWriter -- FileWriter
 */
public class FileWriterDemo1 {
    public static void main(String[] args) throws IOException {
        //创建字符输入流对象
//        InputStreamReader isr = new InputStreamReader(new FileInputStream("java/src/com/shujia/wyh/day12/e.txt"));
        FileReader fr = new FileReader("java/src/com/shujia/wyh/day12/e.txt");
        //创建字符输出流对象
//        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("java/src/com/shujia/wyh/day12/g.txt"));
        FileWriter fw = new FileWriter("java/src/com/shujia/wyh/day12/g2.txt");


        //一次读写一个字符
//        int i = 0;
//        while ((i=fr.read())!=-1){
//            fw.write(i);
//            fw.flush();
//        }

        //一次读写一个字符数组
        char[] chars = new char[1024];
        int length = 0;
        while ((length=fr.read(chars))!=-1){
            fw.write(chars,0,length);
            fw.flush();
        }




        //释放资源
        fw.close();
        fr.close();

    }
}
